package com.guigu.ssm.serivce.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.ssm.mapper.StudentMapper;
import com.guigu.ssm.pojo.Student;
import com.guigu.ssm.serivce.StudentService;
import com.guigu.ssm.utils.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {
    @Autowired(required = false)
    StudentMapper studentMapper;

    @Override
    public PageVo<Student> findStuLimit(Integer page, Integer pageNum,Student student) {
        PageHelper.startPage(page,pageNum);
        List<Student> stuLimit = studentMapper.findStuLimit(student);
        PageInfo<Student> studentPageInfo = new PageInfo<>(stuLimit);
        //System.out.println(studentPageInfo);
        PageVo pageVo = new PageVo();
        pageVo.setTotal(studentPageInfo.getTotal());
        pageVo.setRows(studentPageInfo.getList());
        return pageVo;
    }

    @Override
    public int insert(Student record) {
        return studentMapper.insert(record);
    }

    @Override
    public int deleteByPrimaryKey(Integer empno) {
        return studentMapper.deleteByPrimaryKey(empno);
    }

}
